﻿@model QuanLySanXuat.Models.BillOutFormModels
<div id="form_body">
    <table id="tblBillDetail">
        <thead>
            <tr>
                <th style="width: 150px;"><span>Mã chi tiết phiếu nhập</span></th>
                <th style="width: 150px;"><span>NVL</span></th>
                <th style="width: 150px;"><span>Đơn vị tính</span></th>
                <th style="width: 140px;"><span>Số lượng</span></th>
                <th style="width: 50px;"><span>Giá nhập kho</span></th>
                <th style="width: 100px;"><span>Phí bảo quản</span></th>
                <th style="width: 100px;"><span>Giá xuất kho</span></th>
                <th style="width: 100px;"><span>Thành tiền</span></th>
                <th style="width: 20px;"></th>
            </tr>
        </thead>
        @if (Model != null)
        { 
            <tbody id="insertRow">
                @if (Model.BillDetails != null)
                {
                    foreach (var item in Model.BillDetails)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="BillDetailID" name="BillDetailID" class="BillDetailID" value="@item.ID" />
                            @Html.DropDownList("PurchaseDetailID", new SelectList(ViewData["Purchase"] as IEnumerable<Data.Models.PurchaseDetail>, "ID", "ID", @item.PurchaseDetailID), new { @class = "span2 col-sm-1 form-control" })
                        </td>
                        <td>
                            @Html.DropDownList("MaterialID", new SelectList(ViewData["Material"] as IEnumerable<Data.Models.Material>, "ID", "Name", @item.MaterialID), new { @class = "span2 col-sm-1 form-control  uom", @onchange="GetUOM(this);" })
                        </td>
                        <td>
                            @Html.DropDownList("UOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOMID), new { @class = "span2 col-sm-1 form-control unit" })
                        </td>
                        <td>
                            <input type="text" id="Quantity" name="Quantity" class="txt1 Quantity quantity" value="@item.Quantity" onchange="Total(this);">
                        </td>
                        <td>
                            <input type="text" id="Price_In" name="Price_In" class="txt1 Price_In quantity" value="@item.Price_In" >
                        </td>
                        <td>
                            <input type="text" id="Maintenancecost" name="Maintenancecost" class="txt1 Maintenancecost quantity" value="@item.Maintenancecost"  onchange="Total(this);">
                        </td>
                        <td>
                            <input type="text" id="Price_Out" name="Price_Out" class="txt1 Price_Out quantity" value="@item.Price_Out"  onchange="Total(this);">
                        </td>
                        <td class="total">
                            <input type="text" id="BillDetailsTotalMoney" name="BillDetailsTotalMoney" class="txt1 BillDetailsTotalMoney quantity" value="@item.TotalMoney"  onchange="Total(this);">
                        </td>
                        <td >
                            <div class="remove" id="delRow" onclick="RemoveRow(this,'tblBillDetail');"></div>
                        </td>
                    </tr>
                    }
                }

            </tbody>
        }
        else
        {
            <tbody id="insertRow">
                <tr>
                    <td>
                        <input type="hidden" id="BillDetailID" name="BillDetailID" class="BillDetailID" />
                        @Html.DropDownList("PurchaseDetailID", new SelectList(ViewData["Purchase"] as IEnumerable<Data.Models.PurchaseDetail>, "ID", "ID"), new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("MaterialID", new SelectList(ViewData["Material"] as IEnumerable<Data.Models.Material>, "ID", "Name"), new { @class = "span2 col-sm-1 form-control  uom", @onchange="GetUOM(this);" })
                    </td>
                    <td>
                        @Html.DropDownList("UOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), new { @class = "span2 col-sm-1 form-control unit" })
                    </td>
                    <td>
                        <input type="text" id="Quantity" name="Quantity" class="txt1 Quantity quantity"  onchange="Total(this);">
                    </td>
                    <td>
                        <input type="text" id="Price_In" name="Price_In" class="txt1 Price_In quantity" >
                    </td>
                    <td>
                        <input type="text" id="Maintenancecost" name="Maintenancecost" class="txt1 Maintenancecost quantity"  onchange="Total(this);">
                    </td>
                    <td>
                        <input type="text" id="Price_Out" name="Price_Out" class="txt1 Price_Out quantity"  onchange="Total(this);">
                    </td>
                    <td  class="total">
                        <input type="text" id="BillDetailsTotalMoney" name="BillDetailsTotalMoney" class="txt1 BillDetailsTotalMoney quantity"  onchange="Total(this);"  onchange="Total(this);">
                    </td>
                    <td>
                        <div class="remove" id="delRow" onclick="RemoveRow(this,'tblBillDetail');"></div>
                    </td>
                </tr>
            </tbody>
        }
    </table>
</div>
<div class="tablefooter">
    <div class="pos1">
        <input type="button" id="addline_CreatBill" class="addline" value="Thêm chi tiết phiếu xuất">
    </div>
</div>
<div class="cleardiv"></div>
<div class="btn-group">
    <div class="btn-group">
        <button id="btnSaveSale" type="submit" class="btn btn-defaultxero">Lưu</button>
    </div>
</div>
<div class="btn-group">
    <button id="btnCancelSale" type="button" onclick="javascript: location.href = '/OrderProcess';" class="btn btn-defaultxero">Hủy</button>
</div>
